package com.company;

public class Book implements Item{
    String name;
    String author;
    int year;
    boolean available;


    Book(String bookName, String bookAuthor, int yearOfPub, boolean avail)
    {
        this.name = bookName;
        this.author = bookAuthor;
        this.year = yearOfPub;
        this.available = avail;
    }

    @Override
    public boolean matchesForCheckout (String query)
    {
        return this.name.equalsIgnoreCase(query) && (this.available);

    }
    @Override
    public boolean matchesForReturn(String query)
    {
        return this.name.equalsIgnoreCase(query) && !(this.available);
    }

    @Override
    public void chechoutItem()
    {
        this.available = false;
    }


    @Override
    public void returnItem()
    {
        this.available = true;
    }

    @Override
    public boolean matchesForAvailable()
    {
        return this.available;
    }
    @Override
    public void print(int i)
    {
        System.out.format("%-10d",i);
        System.out.format("%-30s%-30s%-30d", this.name,this.author,this.year);
    }

}